<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title>卖车宝后台登录</title>
    <meta name="keywords" content="卖车宝后台登录">
    <meta name="description" content="卖车宝后台登录">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link href="css/login.css" rel="stylesheet">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>	
	

</head>

<body class="signin">
    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-7">
                <div class="signin-info">
                    <div class="logopanel m-b">
                        <h1>Car</h1>
                    </div>
                    <div class="m-b"></div>
                    <h4>欢迎使用 <strong>卖车宝后台</strong></h4>
                    <ul class="m-b">
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 没有中间商转差价！</li>
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 没有中间商转差价！！</li>
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 没有中间商转差价！！！</li>
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 没有中间商转差价！！！！</li>
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 没有中间商转差价！！！！！</li>
                    </ul>
                    <strong>还没有账号？ <a href="register.html">立即注册&raquo;</a></strong>
                </div>
            </div>
            <div class="col-sm-5">
                <form method="post" onsubmit="return false">
                    <h4 class="no-margins">登录：</h4>
                    <p class="m-t-md">登录到卖车宝后台</p>
                    <input id="userName" type="text" class="form-control uname" placeholder="用户名" />
                    <input id="password" type="password" class="form-control pword m-b" placeholder="密码" />
                    <a href="">忘记密码了？</a>
                    <button id="login" class="btn btn-success btn-block">登录</button>
                </form>
            </div>
        </div>
        <div class="signup-footer">
            <div class="pull-left">
                &copy; 2019 All Rights Reserved. Car
            </div>
        </div>
    </div>
</body>
<!-- 自定义js -->
	<script src="js/vue.min.js"></script>
	<script src="js/axios.min.js"></script>
	<script src="js/config/prefixConfig.js"></script>
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="js/session.js"></script>
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
        
         /**
         * 登录事件
         */
        $("#login").click(function(){
        	var params = new URLSearchParams();
        	params.append("userName",$("#userName").val());
        	params.append("password",$("#password").val());
        	postData("/wxc/userService/login",params).then((res)=>{
        		if(res.data.resultCode == '1') {
        			console.log(res.data.mainData);
			    	var session  = new Session();
			    	session.set("agentId",res.data.mainData.agentId);
			    	session.set("agentName",res.data.mainData.agentName);
			    	session.set("agentAvatar",res.data.mainData.agentAvatar);
					window.location.href="index.html";
        		}else {
                    swal("登录失败", res.data.content, "error");
        		}
        	}).catch((err)=>{
        		console.log(err);
					swal({
	                    title: "服务器错误",
	                    text: err
	       		 	});
				return;
        	})
        });
        
		/**
		 * get数据
		 * @param {Object} url
		 */
		function getData(url) {
			var prefix= new Prefix();
			api = prefix.getPrefix();
			let apiurl = api + url;
			return axios.get(apiurl);
		}
		
		/**
		 * post数据
		 * @param {Object} url
		 * @param {Object} data
		 */
		function postData(url, data) {
			var prefix= new Prefix();
			api = prefix.getPrefix();
			return axios.post(api + url, data)
		}
    </script>
</html>
